﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.IO;

namespace QuanLiBongDa.DataAccessLayer
{
    class ConnectDatabase
    {
        #region "Variable"
        public static SqlConnection _con;
        private static string path = System.IO.Directory.GetCurrentDirectory();
        private static string strconn = @"Data Source=.\SQLEXPRESS;AttachDbFilename=" + path +
                     @"\QLBONGDA.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
        private string _error;
        #endregion
        #region "Properties"
        public string Error
        {
            get { return _error; }
            set { _error = value; }
        }
        #endregion
        #region "Methods"
        public static SqlConnection StartConnect()
        {
            try
            {
                _con = new SqlConnection(strconn);
                return _con;
            }
            catch (System.Exception ex)
            {
                return null;   
            }
            
        }
        public ConnectDatabase(string str)
        {
            strconn = str;
        }
        #endregion
    }
}
